#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$(dirname "$0")")")"
function error {
  echo -e "\\e[31m$1\\e[39m"
  exit 1
}

# Get dependencies
"${DIRECTORY}/pkg-install" "curl libx11-6 libxext6 libegl1-mesa zlib1g libstdc++6 libgl1-mesa-dri libasound2 libcom-err2 libgmp10 libp11-kit0" "$(dirname "$0")" || exit 1

#Download file
cd ~
curl -L https://github.com/ChristopherHX/linux-packaging-scripts/releases/download/v0.2.5-672/Minecraft_Bedrock_Launcher-arm-0.0.672.AppImage --output MCBedrock.AppImage
chmod +x MCBedrock.AppImage
sudo mv MCBedrock.AppImage /opt/MCBedrock.AppImage

#Make Desktop file
echo '[Desktop Entry]
Version=1.1
Type=Application
Name=Minecraft Bedrock Launcher
Comment=A Minecraft: Bedrock Edition
Icon='"$(dirname "$0")/icon-64.png"'
Exec=bash -c "sudo modprobe fuse ; GALLIUM_HUD=simple,fps /opt/MCBedrock.AppImage"
Categories=Game;
Terminal=false
StartupNotify=true' > ~/.local/share/applications/minecraftbedrock.desktop

